//jshint ignore:start
import { defineStore } from "pinia";
import { ref,watch } from "vue";
const toggleView = localStorage.getItem("toggle")?localStorage.getItem("toggle"):1;
export default defineStore("book",()=>{
	const currentIndex = ref(0);
	const toggle = ref(Number(toggleView));
	watch(
		toggle,
		state=>{
			// 每当状态发生变化时，将整个 state 持久化到本地存储。
			localStorage.setItem("toggle",JSON.stringify(state));
		},
		{ deep:true },
	);
	return { currentIndex,toggle };
});
